/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.sisportaria.bean;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author lac
 */
@Entity
@Table(name = "TIPO")
@NamedQueries({@NamedQuery(name = "Tipo.findAll", query = "SELECT t FROM Tipo t"), @NamedQuery(name = "Tipo.findByTpncodg", query = "SELECT t FROM Tipo t WHERE t.tpncodg = :tpncodg"), @NamedQuery(name = "Tipo.findByTpcdesc", query = "SELECT t FROM Tipo t WHERE t.tpcdesc = :tpcdesc"), @NamedQuery(name = "Tipo.PessoaTipo", query = "SELECT t FROM Tipo t WHERE t.tpncodg NOT IN  ( SELECT DISTINCT p.tpncodg from PessoaTipo p WHERE t.tpncodg=p.tpncodg  )")})
public class Tipo implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "TPNCODG")
    private Integer tpncodg;
    @Column(name = "TPCDESC")
    private String tpcdesc;

    public Tipo() {
    }

    public Tipo(Integer tpncodg) {
        this.tpncodg = tpncodg;
    }

    public Integer getTpncodg() {
        return tpncodg;
    }

    public void setTpncodg(Integer tpncodg) {
        Integer oldTpncodg = this.tpncodg;
        this.tpncodg = tpncodg;
        changeSupport.firePropertyChange("tpncodg", oldTpncodg, tpncodg);
    }

    public String getTpcdesc() {
        return tpcdesc;
    }

    public void setTpcdesc(String tpcdesc) {
        String oldTpcdesc = this.tpcdesc;
        this.tpcdesc = tpcdesc;
        changeSupport.firePropertyChange("tpcdesc", oldTpcdesc, tpcdesc);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tpncodg != null ? tpncodg.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tipo)) {
            return false;
        }
        Tipo other = (Tipo) object;
        if ((this.tpncodg == null && other.tpncodg != null) || (this.tpncodg != null && !this.tpncodg.equals(other.tpncodg))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.sisportaria.view.Tipo[tpncodg=" + tpncodg + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
